import { Component } from '../../components/base-component';
import { Button } from '../../components/button';
import { setNavigation } from '../../utilities/navigate';

export class NavigationButtons extends Component {
  private buttonGarage = new Button({
    className: 'button',
    text: 'To Garage',
    disabled: true,
  });

  private buttonWinners = new Button({
    className: 'button',
    text: 'To Winners',
  });

  constructor(state: boolean) {
    super({ tag: 'nav', className: 'nav-buttons' });

    this.chooseDisabled(state);

    this.buttonWinners.addListener('click', () => {
      setNavigation('winners');
    });

    this.buttonGarage.addListener('click', () => {
      setNavigation('garage');
    });

    this.appendChildren([this.buttonGarage, this.buttonWinners]);
  }

  chooseDisabled(state: boolean) {
    if (state) {
      this.buttonWinners.setDisabledState(true);
      this.buttonGarage.setDisabledState(false);
    } else {
      this.buttonGarage.setDisabledState(true);
      this.buttonWinners.setDisabledState(false);
    }
  }
}
